package com.aatrox.bhsypro.controller;

import com.aatrox.bhsypro.entity.AliBean;
import com.aatrox.bhsypro.service.PayService;
import com.alipay.api.AlipayApiException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    protected static final Logger logger = LoggerFactory.getLogger(OrderController.class);
    @Autowired
    private PayService payService;



    @PostMapping(value = "/alipay")
    public String alipay(String outTradeNo, String subject, String totalAmount, String body) throws AlipayApiException {
        AliBean alipayBean = new AliBean();
        alipayBean.setOut_trade_no(outTradeNo);
        alipayBean.setSubject(subject);
        alipayBean.setTotal_amount(totalAmount);
        alipayBean.setBody(body);
        logger.info(alipayBean.toString());
        return payService.aliPay(alipayBean);
    }
}